<template>
  <div class="factory-assessment-box">
    <div class="infoSty">
      <m-iconfont
        classify="m-pc-public"
        icon="m-pc-public_jiesxx"
        color="#4d84ff"
      ></m-iconfont>
      <span>基础信息</span>
    </div>
    <el-form
      ref="baseInfoForm"
      :model="baseInfoForm"
      :rules="essentialInformation"
      :inline="true"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-row>
        <el-col :span="6">
          <el-form-item label="医院名称:" prop="hospitalName">
            <el-input v-model="baseInfoForm.hospitalName" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="医院编码:" prop="hospitalCode">
            <el-input v-model="baseInfoForm.hospitalCode" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="医院简称:" prop="hospitalShortName">
            <el-input v-model="baseInfoForm.hospitalShortName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="签约状态:" prop="signingStatusStr">
            <el-input
              v-model="baseInfoForm.signingStatusStr"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="医院登记号:" prop="hospitalRegisterCode">
            <el-input v-model="baseInfoForm.hospitalRegisterCode"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="法人:" prop="legalPerson">
            <el-input v-model="baseInfoForm.legalPerson"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="成立日期:" prop="createDate">
            <el-date-picker
              v-model="baseInfoForm.createDate"
              type="date"
              placeholder="选择日期"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人:" prop="linkMan">
            <el-input v-model="baseInfoForm.linkMan"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="联系电话:" prop="linkPhone">
            <el-input v-model="baseInfoForm.linkPhone"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所在地区:" prop="province">
            <el-cascader
              v-model="baseInfoForm.area"
              :props="props"
              :placeholder="
                baseInfoForm.province
                  ? baseInfoForm.province +
                    '/' +
                    baseInfoForm.city +
                    '/' +
                    baseInfoForm.county
                  : '请选择所在地区'
              "
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="详细地址:" prop="address">
            <el-input v-model="baseInfoForm.address"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="医院性质:" prop="hospitalNature">
            <el-select v-model="baseInfoForm.hospitalNature">
              <el-option
                v-for="item in hospitalType"
                :key="item.value"
                :value="item.value"
                :label="item.label"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="医院简介:" prop="hospitalIntroduction">
            <el-input
              v-model="baseInfoForm.hospitalIntroduction"
              type="textarea"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <div class="topSty">
        
        
        
        
      </div>
      <div class="topSty">
        
        
        

        
      </div>
      <div class="topSty">
        
        
        
        
      </div>
       -->
    </el-form>
    <div class="tab">
      <tabs
        :tabs-arr="TAB_ARR"
        :active-index="auditStatus"
        @returnIndex="onHandletabs"
      >
        <el-button v-if="auditStatus === 1" type="" @click="newConstructionOff">
          <m-iconfont classify="m-pc-public" icon="m-pc-public_tustjimg" /><span
            >新建</span
          ></el-button
        >
        <el-button
          v-if="auditStatus === 2"
          type=""
          @click="newConstructionSite"
        >
          <m-iconfont classify="m-pc-public" icon="m-pc-public_tustjimg" /><span
            >新建</span
          ></el-button
        >
        <el-button v-if="auditStatus === 3" type="" @click="newConstructionYC">
          <m-iconfont classify="m-pc-public" icon="m-pc-public_tustjimg" /><span
            >新建</span
          ></el-button
        >
      </tabs>
    </div>
    <!-- 财务信息 -->
    <div v-if="auditStatus === 0" class="finance">
      <el-form
        ref="baseInfoForm"
        :model="financeInfoForm"
        :inline="true"
        :rules="essentialInformation"
        label-width="100px"
        class="demo-ruleForm"
      >
        <div class="butSty">
          <el-form-item label="税务登记号:" prop="taxRegistrationNo">
            <el-input v-model="financeInfoForm.taxRegistrationNo"></el-input>
          </el-form-item>
          <el-form-item label="账户名称:" prop="accountName">
            <el-input v-model="financeInfoForm.accountName"></el-input>
          </el-form-item>
          <el-form-item label="对公账户:" prop="publicAccountName">
            <el-input v-model="financeInfoForm.publicAccountName"></el-input>
          </el-form-item>
        </div>
        <div class="butSty">
          <el-form-item label="银行名称:" prop="bankAccount">
            <el-input v-model="financeInfoForm.bankAccount"></el-input>
          </el-form-item>
          <el-form-item label="开户行名称:" prop="bankName">
            <el-input v-model="financeInfoForm.bankName"></el-input>
          </el-form-item>
          <el-form-item label="开户行编码" prop="bankCode">
            <el-input v-model="financeInfoForm.bankCode"></el-input>
          </el-form-item>
        </div>
        <div class="butSty">
          <el-form-item label="财务负责人" prop="financialDirector">
            <el-input v-model="financeInfoForm.financialDirector"></el-input>
          </el-form-item>
          <el-form-item label="联系人" prop="linkMan">
            <el-input v-model="financeInfoForm.linkMan"></el-input>
          </el-form-item>
          <el-form-item label="电话" prop="linkPhone">
            <el-input v-model="financeInfoForm.linkPhone"></el-input>
          </el-form-item>
        </div>
      </el-form>
    </div>
    <!-- 新建科室弹框 -->
    <m-dialog
      title="新建科室信息"
      width="middle"
      confirm-text="保存"
      :visible.sync="showAddFormOff"
      :before-close="handleCloseOff"
      @refuse="handleCloseOff"
      @confirm="toSubmitOff"
      @closeBtn="handleCloseOff"
    >
      <template #content>
        <el-form
          ref="addNewOff"
          :model="addNewOff"
          :rules="addNewOffFormRules"
          label-width="80px"
          class="demo-ruleform"
        >
          <el-form-item label="科室名称" prop="departName">
            <el-input v-model="addNewOff.departName" />
          </el-form-item>
          <el-form-item label="联系人" prop="linkMan">
            <el-input v-model="addNewOff.linkMan" />
          </el-form-item>
          <el-form-item label="联系电话" prop="linkPhone" :maxlength="11">
            <el-input v-model="addNewOff.linkPhone" :maxlength="11" />
          </el-form-item>
          <el-form-item label="是否有效" prop="status">
            <el-select v-model="addNewOff.status" placeholder="请选择">
              <el-option
                v-for="items in statusData"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="省" prop="provinceCode">
            <el-select
              v-model="addNewOff.province"
              placeholder="请选择"
              @change="provinceMethod"
            >
              <el-option
                v-for="items in provinceDataKS"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item prop="cityCode" label="市">
            <el-select
              v-model="addNewOff.city"
              :disabled="!addNewOff.province"
              placeholder="请选择"
              @change="cityMethod"
            >
              <el-option
                v-for="items in cityDataKS"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item prop="countyCode" label="区">
            <el-select
              v-model="addNewOff.county"
              :disabled="!addNewOff.province || !addNewOff.city"
              placeholder="请选择"
              @change="countyMethod"
            >
              <el-option
                v-for="items in countyDataKS"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="详细地址" prop="address">
            <el-input v-model="addNewOff.address" />
          </el-form-item>
        </el-form>
      </template>
    </m-dialog>
    <!-- 新建收件地址 -->

    <m-dialog
      title="新建收件地址"
      width="middle"
      confirm-text="保存"
      :visible.sync="showAddFormSite"
      :before-close="handleCloseSite"
      @refuse="handleCloseSite"
      @confirm="toSubmitSite"
      @closeBtn="handleCloseSite"
    >
      <template #content>
        <div class="address-form-wrapper">
          <el-form
            ref="editConsigneeAddress"
            :model="editConsigneeAddress"
            :rules="addNewOffFormRules2"
            label-position="right"
            label-width="80px"
          >
            <el-form-item label="收件科室" prop="departCode">
              <el-select
                v-model="editConsigneeAddress.departCode"
                placeholder="请选择"
              >
                <el-option
                  v-for="items in officList"
                  :key="items.code"
                  :label="items.name"
                  :value="items.code"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="联系人" prop="linkMan">
              <el-input v-model="editConsigneeAddress.linkMan" />
            </el-form-item>
            <el-form-item label="联系电话" prop="linkPhone" maxlength="11">
              <el-input
                v-model="editConsigneeAddress.linkPhone"
                :maxlength="11"
              />
            </el-form-item>
            <el-form-item label="是否默认" prop="defaultStatus">
              <el-select
                v-model="editConsigneeAddress.defaultStatus"
                placeholder="请选择"
              >
                <el-option
                  v-for="items in statusDataNewSJ"
                  :key="items.value"
                  :label="items.label"
                  :value="items.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="省" prop="provinceCode">
              <el-select
                v-model="editConsigneeAddress.province"
                placeholder="请选择"
                @change="provinceMethodSJ"
              >
                <el-option
                  v-for="items in provinceDataSJ"
                  :key="items.value"
                  :label="items.label"
                  :value="items.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item prop="cityCode" label="市">
              <el-select
                v-model="editConsigneeAddress.city"
                :disabled="!editConsigneeAddress.province"
                placeholder="请选择"
                @change="cityMethodSJ"
              >
                <el-option
                  v-for="items in cityDataSJ"
                  :key="items.value"
                  :label="items.label"
                  :value="items.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item prop="countyCode" label="区">
              <el-select
                v-model="editConsigneeAddress.county"
                placeholder="请选择"
                @change="countyMethodSJ"
              >
                <el-option
                  v-for="items in countyDataSJ"
                  :key="items.value"
                  :label="items.label"
                  :value="items.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="详细地址" prop="address">
              <el-input v-model="editConsigneeAddress.address" />
            </el-form-item>
            <el-form-item label="标签" prop="tag">
              <el-input v-model="editConsigneeAddress.tag" />
            </el-form-item>
          </el-form>
        </div>
      </template>
    </m-dialog>
    <!-- 阳采 -->

    <m-dialog
      title="新建阳采"
      width="middle"
      confirm-text="保存"
      :visible.sync="showAddFormYC"
      :before-close="handleCloseYC"
      @refuse="handleCloseYC"
      @confirm="toSubmitYC"
      @closeBtn="handleCloseYC"
    >
      <template #content>
        <el-form
          ref="addFormYC"
          :model="addFormYC"
          :rules="addNewOffFormRules3"
          label-position="right"
          label-width="100px"
        >
          <el-form-item
            label="阳光平台配送编码"
            prop="sunshinePlatHospitalCode"
          >
            <el-input v-model="addFormYC.sunshinePlatHospitalCode" />
          </el-form-item>
          <el-form-item label="配送点编码" prop="distributionCode">
            <el-input v-model="addFormYC.distributionCode" />
          </el-form-item>
          <el-form-item label="配送点名称" prop="distributionName">
            <el-input v-model="addFormYC.distributionName" />
          </el-form-item>
          <el-form-item label="联系人" prop="linkMan">
            <el-input v-model="addFormYC.linkMan" />
          </el-form-item>
          <el-form-item label="联系电话" prop="linkPhone" maxlength="11">
            <el-input v-model="addFormYC.linkPhone" :maxlength="11" />
          </el-form-item>
          <el-form-item label="邮政编码" prop="postalCode">
            <el-input v-model="addFormYC.postalCode" />
          </el-form-item>
          <el-form-item label="是否默认" prop="">
            <el-select v-model="addFormYC.defaultStatus" placeholder="请选择">
              <el-option
                v-for="items in statusDataNewYC"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="省" prop="provinceCode">
            <el-select
              v-model="addFormYC.province"
              placeholder="请选择"
              @change="provinceMethodYC"
            >
              <el-option
                v-for="items in provinceDataYC"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item prop="cityCode" label="市">
            <el-select
              v-model="addFormYC.city"
              placeholder="请选择"
              @change="cityMethodYC"
            >
              <el-option
                v-for="items in cityDataYC"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item prop="countyCode" label="区">
            <el-select
              v-model="addFormYC.county"
              placeholder="请选择"
              @change="countyMethodYC"
            >
              <el-option
                v-for="items in countyDataYC"
                :key="items.value"
                :label="items.label"
                :value="items.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="详细地址" prop="address">
            <el-input v-model="addFormYC.address" />
          </el-form-item>
          <el-form-item label="备注" prop="remarks">
            <el-input v-model="addFormYC.remarks" />
          </el-form-item>
        </el-form>
      </template>
    </m-dialog>

    <!-- 科室信息列表 -->
    <m-editable
      v-if="auditStatus === 1"
      key="ks"
      v-loading="table.tableLoading"
      :empty-type="table.resultType"
      :data="table.dataList"
      :columns="COLUMNS_TABLE"
      height="400"
    >
      <template slot="default-address" slot-scope="scope">
        {{
          scope.row.county &&
          scope.row.province +
            scope.row.city +
            scope.row.county +
            (scope.row.address || '')
        }}
      </template>
      <template slot="default-action" slot-scope="scope">
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="handleEditAddressItem(scope)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="toDeleteaDministrative(scope.row)"
          >删除</el-button
        >
      </template>
    </m-editable>

    <!-- 编辑科室弹框 -->
    <Add-offic-dialog
      ref="upload"
      :dialog-visible.sync="addressDialogShow"
      :form-data="currentAddress"
      :loading="submitLoading"
      @done="reSearch"
      @confirmDialog="handleSubmitAddress"
      @closeDialog="handleCancelSubmit"
    />
    <!-- 收货地址编辑弹框 -->
    <consignee-Address-Dialog
      ref="uploadConsignee"
      :dialog-visible.sync="ConsigneeDialogShow"
      :form-data="consigneeCurrentAddress"
      :loading="submitLoading"
      @dones="reSearchConsignee"
      @confirmDialogConsignee="handleSubmitAddressConsignee"
      @closeDialogConsignee="handleCancelSubmitConsignee"
    >
    </consignee-Address-Dialog>
    <!-- 阳采编辑弹框 -->
    <distributionYCDialog
      ref="uploadDistributionYC"
      :dialog-visible.sync="distributionYCDialogShow"
      :form-data="distributionYCCurrentAddress"
      :loading="submitLoading"
      @donees="reSearchDistributionYC"
      @confirmDialogYC="handleSubmitAddressdistributionYC"
      @closeDialogYC="handleCancelSubmitYC"
    >
    </distributionYCDialog>

    <!-- 分页模块 -->
    <div v-if="auditStatus === 1" class="footer">
      <el-pagination
        class="pageBox"
        align="right"
        :page-size="page.size"
        :current-page="page.curPage"
        :total="page.total"
        :layout="page.PAGINATION_LAYOUT"
        :page-sizes="page.PAGE_NUMBER"
        @size-change="onPageSizeChange"
        @current-change="onPageCurrentChange"
      />
    </div>
    <!-- 收件地址列表 -->
    <m-editable
      v-if="auditStatus === 2"
      key="address"
      v-loading="table.tableLoading"
      :empty-type="table.resultType"
      :data="table.dataListTwo"
      :columns="COLUMNS_TABLE_SITE"
      height="800"
    >
      <template slot="default-area" slot-scope="scope">
        {{
          scope.row.county &&
          scope.row.province + scope.row.city + scope.row.county
        }}
      </template>
      <template slot="default-action" slot-scope="scope">
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="handleEditAddressConsignee(scope)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="toDeleteaConsigneeAddress(scope.row)"
          >删除</el-button
        >
      </template>
    </m-editable>
    <div v-if="auditStatus === 2" class="footer">
      <el-pagination
        class="pageBox"
        align="right"
        :page-size="page.size"
        :current-page="page.curPage"
        :total="page.total"
        :layout="page.PAGINATION_LAYOUT"
        :page-sizes="page.PAGE_NUMBER"
        @size-change="onPageSizeChange"
        @current-change="onPageCurrentChange"
      />
    </div>

    <!-- 阳采配送点 -->
    <m-editable
      v-if="auditStatus === 3"
      key="yc"
      v-loading="table.tableLoading"
      :empty-type="table.resultType"
      :data="table.dataList_purchase"
      :columns="yangCai"
      height="800"
    >
      <template slot="default-address" slot-scope="scope">
        {{
          scope.row.county &&
          scope.row.province +
            scope.row.city +
            scope.row.county +
            scope.row.address
        }}
      </template>
      <template slot="default-action" slot-scope="scope">
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="handleEditAddressdistributionYC(scope)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="primary"
          plain
          @click.stop="toDeleteDistributionSitesYC(scope.row)"
          >删除</el-button
        >
      </template>
    </m-editable>
    <div v-if="auditStatus === 3" class="footer">
      <el-pagination
        class="pageBox"
        align="right"
        :page-size="page.size"
        :current-page="page.curPage"
        :total="page.total"
        :layout="page.PAGINATION_LAYOUT"
        :page-sizes="page.PAGE_NUMBER"
        @size-change="onPageSizeChange"
        @current-change="onPageCurrentChange"
      />
    </div>
  </div>
</template>
<script>
/* eslint-disable */

import tabs from '@pc/m-components/m-tabs/index.vue';
import { PAGE_NUMBER, PAGINATION_LAYOUT } from '@const/common';
import {
  hospitalRecordsDetails,
  getDepartmentInformation,
  getConsigneeAddress,
  getDistributionSitesYC,
  deleteDepartmentInformation,
  deleteConsigneeAddress,
  deleteDistributionSitesYC,
  editOffice,
  editConsignee,
  editdistributionYC,
  editSumbit,
  editSumbitOff,
  editSumbitSite,
  editKSList,
  editSumbitYC,
  editOfficeList,
  detailsYCChange,
} from '@api/hossyn-order-center';
import { phone, realName } from '@const/formValidate';
import AddOfficDialog from './editComponent/addOfficDialog';
import consigneeAddressDialog from './editComponent/consigneeAddress';
import distributionYCDialog from './editComponent/distributionYC';

import { TAB_ARR, COLUMNS_TABLE, COLUMNS_TABLE_SITE, yangCai } from './const';

export default {
  components: {
    tabs,
    AddOfficDialog,
    consigneeAddressDialog,
    distributionYCDialog,
  },
  data() {
    return {
      props: {
        lazy: true,
        lazyLoad: async (node, resolve) => {
          const { level, value } = node;

          const params = {};
          if (level === 0) {
            params.countryCode = 'CN';
          } else if (level === 1) {
            params.provinceCode = value;
          } else if (level === 2) {
            params.cityCode = value;
          }
          const { data } = await this.$axios({
            method: 'get',
            url: this.queryArea,
            params,
          });
          const { payload } = data;
          this.chianCountry[level] = payload;
          const nodes = Object.keys(payload).map((item) => ({
            label: payload[item],
            value: item,
            leaf: level >= 2,
          }));
          resolve(nodes);
        },
      },
      chianCountry: [],
      cascaderOptions: [],
      countryLevel: 0,
      baseInfoForm: {
        hospitalName: '',
        hospitalCode: '',
        hospitalRegisterCode: '',
        hospitalShortName: '',
        signingStatus: '',
        legalPerson: '',
        createDate: '',
        linkMan: '',
        linkPhone: '',
        hospitalNature: '',
        province: '',
        city: '',
        county: '',
        address: '',
        hospitalIntroduction: '',
      },
      financeInfoForm: {
        taxRegistrationNo: '',
        accountName: '',
        publicAccountName: '',
        bankAccount: '',
        bankName: '',
        bankCode: '',
        financialDirector: '',
        linkMan: '',
        linkPhone: '',
      },
      provinceDataKS: [],
      cityDataKS: [],
      countyDataKS: [],
      provinceDataSJ: [],
      cityDataSJ: [],
      countyDataSJ: [],
      provinceDataYC: [],
      cityDataYC: [],
      countyDataYC: [],
      addNewOff: {
        // 新建科室
        departName: '',
        linkMan: '',
        linkPhone: '',
        province: '',
        address: '',
        status: '',
        cityId: '',
        city: '',
        county: '',
        detailedAddress: '',
        location: [],
        provinceId: '',
      },
      editConsigneeAddress: {
        tag: '',
        departName: '',
        departCode: '',
        linkMan: '',
        linkPhone: '',
        province: '',
        address: '',
        defaultStatus: '',
        cityId: '',
        city: '',
        county: '',
        detailedAddress: '',
        provinceId: '',
      },
      addFormYC: {
        sunshinePlatHospitalCode: '',
        distributionCode: '',
        distributionName: '',
        postalCode: '',
        remarks: '',
        departName: '',
        linkMan: '',
        linkPhone: '',
        province: '',
        address: '',
        defaultStatus: '',
        county: '',
        cityId: '',
        city: '',

        detailedAddress: '',
        provinceId: '',
      },
      COLUMNS_TABLE,
      COLUMNS_TABLE_SITE,
      yangCai,
      TAB_ARR,
      ruleForm: {},
      auditStatus: 0,
      table: {
        tableLoading: false,
        confirmLoadingOff: false,
        resultType: 0,
        dataList: [],
        searchData: {},
        dataListTwo: [],
        dataList_purchase: [],
        financeInfoForm: {},
        baseInfoForm: {},
      },
      showAddForm: false,
      confirmLoading: false,
      addForm: {
        status: '',
      },
      statusData: [
        { label: '是', value: 0 },
        { label: '否', value: 1 },
      ],
      statusDataNewSJ: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
      statusDataNewYC: [
        { label: '是', value: 0 },
        { label: '否', value: 1 },
      ],
      options: [
        {
          lable: '有效',
          value: 0,
        },
        {
          lable: '无效',
          value: 1,
        },
      ],
      compileYCid: '',
      distributionIdYCD: '',
      submitLoading: false,
      addressDialogShow: false,
      ConsigneeDialogShow: false,
      distributionYCDialogShow: false,
      showAddFormSite: false,
      showAddFormYC: false,
      addressList: [],
      officList: [],
      consigneeCurrentAddress: {},
      distributionYCCurrentAddress: {},
      currentAddress: {}, // 编辑地址时需要传递进弹窗的当前地址数据，要注意接口返回的数据格式和form中的格式差异处理
      isEdit: false, // 判断当前是新建地址还是编辑地址，用于确定发送的接口请求
      isEditConsignee: false,
      isEditdistributionYC: false,
      rulesAdd: {},
      addNewOffFormRules: {
        departName: [
          { required: true, message: '请输入科室名称', trigger: 'change' },
        ],
        linkMan: [
          { required: true, message: '请输入联系人', trigger: 'change' },
        ],
        linkPhone: phone(),
        // status: [
        //   { required: true, message: '请选择是否有效', trigger: 'change' },
        // ],
        // provinceCode: [
        //   { required: true, message: '请输入省', trigger: 'change' },
        // ],
        // cityCode: [{ required: true, message: '请输入市', trigger: 'change' }],
        // countyCode: [
        //   { required: true, message: '请输入区', trigger: 'change' },
        // ],
        // address: [
        //   { required: true, message: '请输入详细地址', trigger: 'change' },
        // ],
      },
      addNewOffFormRules2: {
        departCode: [
          { required: true, message: '请输入科室名称', trigger: 'change' },
        ],
        linkMan: [
          { required: true, message: '请输入联系人', trigger: 'change' },
        ],
        linkPhone: phone(),
        // status: [
        //   { required: true, message: '请选择是否有效', trigger: 'change' },
        // ],
        // provinceCode: [
        //   { required: true, message: '请输入省', trigger: 'change' },
        // ],
        // cityCode: [{ required: true, message: '请输入市', trigger: 'change' }],
        // countyCode: [
        //   { required: true, message: '请输入区', trigger: 'change' },
        // ],
        // address: [
        //   { required: true, message: '请输入详细地址', trigger: 'change' },
        // ],
      },
      addNewOffFormRules3: {
        sunshinePlatHospitalCode: [
          {
            required: true,
            message: '请输入阳光平台配送编码',
            trigger: 'change',
          },
        ],
        distributionCode: [
          { required: true, message: '请输入配送点编码', trigger: 'change' },
        ],
        distributionName: [
          { required: true, message: '请输入配送点名称', trigger: 'change' },
        ],
        linkMan: [
          { required: true, message: '请输入联系人', trigger: 'change' },
        ],
        linkPhone: phone(),
        // status: [
        //   { required: true, message: '请选择是否有效', trigger: 'change' },
        // ],
        // provinceCode: [
        //   { required: true, message: '请输入省', trigger: 'change' },
        // ],
        // cityCode: [{ required: true, message: '请输入市', trigger: 'change' }],
        // countyCode: [
        //   { required: true, message: '请输入区', trigger: 'change' },
        // ],
        // address: [
        //   { required: true, message: '请输入详细地址', trigger: 'change' },
        // ],
      },
      page: {
        PAGE_NUMBER, // 页码数组
        PAGINATION_LAYOUT, // 页码功能布局
        curPage: 1,
        pageSize: PAGE_NUMBER[0],
        total: 0,
      },
      showAddFormOff: false,
      queryArea: '/guoke-deepexi-interface-center/api/v1/mdm/code/area/list', // 省市查询接口
      essentialInformation: {
        // 基本信息和财务信息校验
        hospitalRegisterCode: [
          { required: true, message: '请输入医院登记号', trigger: 'blur' },
        ],
        linkMan: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
        linkPhone: [
          { required: true, message: '请输入联系电话', trigger: 'blur' },
        ],
        taxRegistrationNo: [
          { required: true, message: '请输入税务登记号', trigger: 'blur' },
        ],
        accountName: [
          { required: true, message: '请输入账户名称', trigger: 'blur' },
        ],
        publicAccountName: [
          { required: true, message: '请输入对公账户', trigger: 'blur' },
        ],
        bankAccount: [
          { required: true, message: '请输入银行名称', trigger: 'blur' },
        ],
        bankName: [
          { required: true, message: '请输入开户行名称', trigger: 'blur' },
        ],
        bankCode: [
          { required: true, message: '请输入开户行编码', trigger: 'blur' },
        ],
      },
      hospitalType: [
        {
          label: '公立',
          value: 1,
        },
        {
          label: '民营',
          value: 2,
        },
        {
          label: '其他',
          value: 3,
        },
      ],
    };
  },
  computed: {
    country() {
      return (
        this.baseInfoForm.province +
        this.baseInfoForm.city +
        this.baseInfoForm.county
      );
    },
  },
  created() {
    this.hospitalRecordsDetails();
    this.buttonMethod();
  },
  methods: {
    //  右上角按钮
    buttonMethod() {
      const arr = [
        // { type: 'button', val: '返回', handle: this.back },
        { type: 'primary', val: '提交', handle: this.tosumbitValid },
      ];
      const btn = {
        type: 'btn',
        arr,
      };
      this.$store.commit('changeLayoutHandle', btn);
    },
    //  收货地址中的弹框中的收件科室列表
    editKSList() {
      const hospitalCode = {
        hospitalCode: this.$route.query.hospitalCode,
      };
      this.$axios({
        url: editKSList,
        method: 'post',
        data: hospitalCode,
      })
        .then((res) => {
          this.officList = res.data.payload;
          console.log(res.data.payload, 'res.data.payload0000');
        })
        .catch((err) => {});
    },
    tosumbitValid() {
      this.$refs.baseInfoForm.validate((valid) => {
        if (valid) {
          this.tosumbit();
        } else {
          return false;
        }
      });
    },
    //  提交基本信息和财务信息
    tosumbit() {
      const postData = {
        baseInfoForm: this.baseInfoForm,
        financeInfoForm: this.financeInfoForm,
        hospitalCode: this.$route.query.hospitalCode,
      };

      if (this.baseInfoForm.area) {
        const arr = ['province', 'city', 'county'];
        this.baseInfoForm.area.forEach((item, index) => {
          const areaItem = this.chianCountry[index][item];
          this.baseInfoForm[`${arr[index]}`] = areaItem;
          this.baseInfoForm[`${arr[index]}Code`] = item;
        });
      }

      this.$axios
        .$post(editSumbit, postData)
        .then((res) => {
          //  console.log(res,'res66666')
          if (res.code === '0') {
            this.$message({
              message: '提交成功',
              type: 'success',
            });
          }
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    reSearch() {},
    reSearchConsignee() {},
    reSearchDistributionYC() {},
    //  科室确认弹框
    handleSubmitAddress(data) {
      this.submitLoading = true;
      const postData = {
        ...data,
      };
      this.$axios
        .$post(editOffice, postData)
        .then((res) => {
          this.submitLoading = false;
          this.addressDialogShow = false;
          this.getDepartmentInformationList();
          this.$message({
            message: '编辑成功',
            type: 'success',
          });
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    // 收货地址确认
    handleSubmitAddressConsignee(dataConsignee) {
      this.submitLoading = true;

      const postData = {
        ...dataConsignee,
        hosBaseId: this.baseInfoForm.hosBaseId,
        distributionId: '1',
        distributionCode: '2',
        distributionName: '3',
      };
      this.$axios
        .$post(editConsignee, postData)
        .then((res) => {
          this.submitLoading = false;
          this.ConsigneeDialogShow = false;
          this.getConsigneeAddressList();
          this.$message({
            message: '编辑成功',
            type: 'success',
          });
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    // 阳采确认--编辑确认
    handleSubmitAddressdistributionYC(data) {
      this.submitLoading = true;
      console.log(this.compileYCid, 'llllll');
      // let distributionId=this.compileYCid,

      const postData = {
        ...data,
        distributionId: this.compileYCid,
      };
      this.$axios
        .$post(editdistributionYC, postData)
        .then((res) => {
          this.distributionYCDialogShow = false;
          this.getDistributionSitesYCList();
          this.$message({
            message: '编辑成功',
            type: 'success',
          });
        })
        .finally((err) => {
          this.submitLoading = false;
        });
    },

    // 关闭收货地址弹框
    handleCancelSubmitConsignee() {
      this.consigneeCurrentAddress = {};
      this.ConsigneeDialogShow = false;
    },

    // 关闭科室信息弹框
    handleCancelSubmit() {
      this.currentAddress = {};
      this.addressDialogShow = false;
    },
    // 关闭阳采distributionYCDialogShow
    handleCancelSubmitYC() {
      this.distributionYCDialogShow = false;
      this.distributionYCCurrentAddress = {};
    },
    //  切换表头
    onHandletabs(val) {
      this.page.curPage = 1;
      this.auditStatus = val;
      if (val === 1) {
        this.getDepartmentInformationList();
      } else if (val === 2) {
        this.getConsigneeAddressList();
      } else {
        this.getDistributionSitesYCList();
      }
    },
    // 点击分页事件
    onPageSizeChange(size) {
      this.page.pageSize = size;
    },
    onPageCurrentChange(curPage) {
      this.page.curPage = curPage;
    },
    // 医院档案--详情---基本信息和财务信息
    hospitalRecordsDetails() {
      this.tableLoading = true;
      this.$axios({
        url: hospitalRecordsDetails,
        method: 'post',
        data: {
          hospitalCode: this.$route.query.hospitalCode,
          // page: this.page.curPage,
          // pageSize: this.page.pageSize,
        },
      })
        .then((res) => {
          this.baseInfoForm = res.data.payload.baseInfo || {};
          // this.baseInfoForm.area = [
          //   this.baseInfoForm.provinceCode,
          //   this.baseInfoForm.cityCode,
          //   this.baseInfoForm.countyCode,
          // ];
          this.financeInfoForm = res.data.payload.financeInfo || {};
          this.page.total = res.data.payload.totalElements;
          if (this.page.total == 0) {
            this.paging = false;
          }
          // this.getChianCountry(res.data.payload.baseInfo);
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    async getChianCountry(baseInfo) {
      const params = {};
      if (this.countryLevel === 0) {
        params.countryCode = 'CN';
      } else if (this.countryLevel === 1) {
        params.provinceCode = baseInfo.provinceCode;
      } else if (this.countryLevel === 2) {
        params.cityCode = baseInfo.cityCode;
      }
      const { data } = await this.$axios({
        method: 'get',
        url: this.queryArea,
        params,
      });
      const { payload } = data;

      if (this.countryLevel === 0) {
        this.cascaderOptions = Object.keys(payload).map((item) => ({
          label: payload[item],
          value: item,
          children: [],
        }));
      } else if (this.countryLevel === 1) {
        const index = this.cascaderOptions.findIndex(
          (item) => item.value === baseInfo.provinceCode
        );
        this.cascaderOptions[index].children = Object.keys(payload).map(
          (item) => ({
            label: payload[item],
            value: item,
            children: [],
          })
        );
      } else if (this.countryLevel === 2) {
        const index = this.cascaderOptions.findIndex(
          (item) => item.value === baseInfo.provinceCode
        );
        const cityIndex = this.cascaderOptions[index].children.findIndex(
          (item) => item.value === baseInfo.cityCode
        );
        this.cascaderOptions[index].children[cityIndex].children = Object.keys(
          payload
        ).map((item) => ({
          label: payload[item],
          value: item,
        }));
      }
      // this.chianCountry[this.countryLevel] = payload;
      if (this.countryLevel < 2) {
        this.countryLevel++;
        this.getChianCountry(baseInfo);
      }
    },
    // 新建科室弹框打开
    newConstructionOff() {
      this.addNewOff = {};
      this.getDefaultProvinceData();
      this.showAddFormOff = true;
    },
    // 新建收货弹框打开
    newConstructionSite() {
      this.editKSList();
      this.getDefaultProvinceDataSJ();
      this.showAddFormSite = true;
    },
    newConstructionYC() {
      this.getDefaultProvinceDataYC();
      this.showAddFormYC = true;
    },
    // 新建科室弹框确认editSumbitOff
    toSubmitOff() {
      this.$refs.addNewOff.validate((valid) => {
        if (valid) {
          const province = this.provinceDataKS.find(
            (item) => item.value === this.addNewOff.province
          );
          const city = this.cityDataKS.find(
            (item) => item.value === this.addNewOff.city
          );
          const county = this.countyDataKS.find(
            (item) => item.value === this.addNewOff.county
          );

          const postData = {
            // addNewOff:this.addNewOff,
            hospitalCode: this.$route.query.hospitalCode,
            departName: this.addNewOff.departName,
            linkMan: this.addNewOff.linkMan,
            linkPhone: this.addNewOff.linkPhone,
            status: this.addNewOff.status,
            province: province ? province.label : '',
            provinceCode: province ? province.value : '',
            city: city ? city.label : '',
            cityCode: city ? city.value : '',
            county: county ? county.label : '',
            countyCode: county ? county.value : '',
            address: this.addNewOff.address,
          };
          this.$axios({
            url: editSumbitOff,
            method: 'post',
            data: postData,
          })
            .then((res) => {
              this.addNewOff = {};
              this.showAddFormOff = false;
              this.getDepartmentInformationList();
              this.$message({
                message: '添加成功',
                type: 'success',
              });
              this.addNewOff = this.$options.data().addNewOff;
            })
            .catch((err) => {
              console.log(err);
            });
        }
      });
    },
    // 新建收件地址
    toSubmitSite() {
      this.$refs.editConsigneeAddress.validate((valid) => {
        if (valid) {
          const depart = this.officList.find(
            (item) => item.code === this.editConsigneeAddress.departCode
          );

          const province = this.provinceDataSJ.find(
            (item) => item.value === this.editConsigneeAddress.province
          );
          const city = this.cityDataSJ.find(
            (item) => item.value === this.editConsigneeAddress.city
          );
          const county = this.countyDataSJ.find(
            (item) => item.value === this.editConsigneeAddress.county
          );

          const postData = {
            // editConsigneeAddress:this.editConsigneeAddress,
            hospitalCode: this.$route.query.hospitalCode,
            departCode: depart.code,
            departName: depart.name,
            linkMan: this.editConsigneeAddress.linkMan,
            linkPhone: this.editConsigneeAddress.linkPhone,
            defaultStatus: this.editConsigneeAddress.defaultStatus,
            province: province ? province.label : '',
            provinceCode: province ? province.value : '',
            city: city ? city.label : '',
            cityCode: city ? city.value : '',
            county: county ? county.label : '',
            countyCode: county ? county.value : '',
            address: this.editConsigneeAddress.address,
            tag: this.editConsigneeAddress.tag,
          };
          this.$axios({
            url: editSumbitSite,
            method: 'post',
            data: postData,
          })
            .then((res) => {
              this.showAddFormSite = false;
              this.getConsigneeAddressList();
              this.$message({
                message: '添加成功',
                type: 'success',
              });
              this.editConsigneeAddress =
                this.$options.data().editConsigneeAddress;
            })
            .catch((err) => {
              console.log(err, '993------');
            });
        }
      });
    },
    // 新建阳采
    toSubmitYC() {
      this.$refs.addFormYC.validate((valid) => {
        if (valid) {
          const province = this.provinceDataYC.find(
            (item) => item.value === this.addFormYC.province
          );
          const city = this.cityDataYC.find(
            (item) => item.value === this.addFormYC.city
          );
          const county = this.countyDataYC.find(
            (item) => item.value === this.addFormYC.county
          );

          const postData = {
            hospitalCode: this.$route.query.hospitalCode,
            distributionCode: this.addFormYC.distributionCode,
            distributionName: this.addFormYC.distributionName,
            sunshinePlatHospitalCode: this.addFormYC.sunshinePlatHospitalCode,
            address: this.addFormYC.address,
            linkMan: this.addFormYC.linkMan,
            linkPhone: this.addFormYC.linkPhone,
            postalCode: this.addFormYC.postalCode,
            defaultStatus: this.addFormYC.defaultStatus,
            province: province ? province.label : '',
            provinceCode: province ? province.value : '',
            city: city ? city.label : '',
            cityCode: city ? city.value : '',
            county: county ? county.label : '',
            countyCode: county ? county.value : '',
            remarks: this.addFormYC.remarks,
          };

          this.$axios({
            url: editSumbitYC,
            method: 'post',
            data: postData,
          })
            .then((res) => {
              this.showAddFormYC = false;
              this.getDistributionSitesYCList();
              this.$message({
                message: '添加成功',
                type: 'success',
              });
              this.addFormYC = this.$options.data().addFormYC;
            })
            .catch((err) => {
              console.log(err);
            });
        }
      });
    },
    //   关闭添加弹框
    handleCloseOff() {
      // this.$refs['ruleAddForm'].resetFields()
      this.addNewOff = {};
      this.showAddFormOff = false;
    },
    handleCloseSite() {
      this.showAddFormSite = false;
    },
    handleCloseYC() {
      this.showAddFormYC = false;
    },
    // 科室列表
    getDepartmentInformationList() {
      this.tableLoading = true;
      this.$axios({
        url: getDepartmentInformation,
        method: 'post',
        data: {
          // departId
          hospitalCode: this.$route.query.hospitalCode,
          page: this.page.curPage,
          pageSize: this.page.pageSize,
        },
      })
        .then((res) => {
          this.table.dataList = res.data.payload.content;
          this.page.total = res.data.payload.totalElements;
          if (this.page.total == 0) {
            this.paging = false;
          }
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    // 删除科室
    toDeleteaDministrative(row) {
      this.$mdialog({
        type: 'warning',
        message: '此操作将永久删除, 是否继续?',
        'confirm-text': '确定',
        'refuse-text': '取消',
      })
        .then(() => {
          this.tableLoading = true;
          this.$axios({
            url: deleteDepartmentInformation,
            method: 'post',
            data: {
              departId: row.departId,
            },
          }).then((res) => {
            this.getDepartmentInformationList();
          });
        })
        .finally((err) => {
          console.log(err);
        });
    },
    // 编辑科室
    handleEditAddressItem(scope) {
      this.isEdit = true;
      this.getDefaultProvinceData();
      this.currentAddress = scope.row;
      this.addressDialogShow = true;
    },
    // 编辑收货地址
    handleEditAddressConsignee(scope) {
      this.isEditConsignee = true;
      this.editKSList();
      this.getDefaultProvinceDataSJ();
      this.consigneeCurrentAddress = scope.row;
      this.ConsigneeDialogShow = true;
    },
    // 编辑阳采时调用此接口，为了获得收货地址id
    detailsYCChangeMethod() {
      // console.log(row,'scope')
      this.$axios({
        url: detailsYCChange,
        method: 'post',
        data: {
          distributionId: this.distributionIdYCD,
          hospitalCode: this.$route.query.hospitalCode,
          page: this.page.curPage,
          pageSize: this.page.pageSize,
        },
      })
        .then((res) => {
          this.compileYCid = res.data.payload.distributionId;
          console.log(res, '1410141014101410');
          console.log(this.compileYCid, '1418');
          console.log(res.data.payload.distributionId, '14151415');
        })
        .catch((err) => {});
    },
    //  编辑阳采
    handleEditAddressdistributionYC(scope) {
      // this.detailsYCChangeMethod()
      console.log(scope, 'scope');
      this.distributionIdYCD = scope.row.distributionId;
      this.detailsYCChangeMethod();
      this.isEditdistributionYC = true;
      this.distributionYCCurrentAddress = scope.row;
      this.distributionYCDialogShow = true;
    },

    // 收件地址
    getConsigneeAddressList() {
      this.tableLoading = true;
      this.$axios({
        url: getConsigneeAddress,
        method: 'post',
        data: {
          // departId
          hospitalCode: this.$route.query.hospitalCode,
          page: this.page.curPage,
          pageSize: this.page.pageSize,
        },
      })
        .then((res) => {
          this.table.dataListTwo = res.data.payload.content;

          this.page.total = res.data.payload.totalElements;
          if (this.page.total == 0) {
            this.paging = false;
          }
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    // 删除收货地址
    toDeleteaConsigneeAddress(row) {
      this.$mdialog({
        type: 'warning',
        message: '此操作将永久删除, 是否继续?',
        'confirm-text': '确定',
        'refuse-text': '取消',
      })
        .then(() => {
          this.tableLoading = true;
          this.$axios({
            url: deleteConsigneeAddress,
            method: 'post',
            data: {
              recevieAddressId: row.recevieAddressId,
            },
          }).then((res) => {
            this.getConsigneeAddressList();
          });
        })
        .finally((err) => {
          console.log(err);
        });
    },
    // 阳采配送点
    getDistributionSitesYCList() {
      this.tableLoading = true;
      this.$axios({
        url: getDistributionSitesYC,
        method: 'post',
        data: {
          // departId
          hospitalCode: this.$route.query.hospitalCode,
          page: this.page.curPage,
          pageSize: this.page.pageSize,
        },
      })
        .then((res) => {
          this.table.dataList_purchase = res.data.payload.content;
          console.log(
            this.table.dataList_purchase,
            'this.table.dataList_purchase22'
          );
          this.page.total = res.data.payload.totalElements;
          if (this.page.total == 0) {
            this.paging = false;
          }
        })
        .finally((err) => {
          this.tableLoading = false;
        });
    },
    // 删除阳采
    toDeleteDistributionSitesYC(row) {
      this.$mdialog({
        type: 'warning',
        message: '此操作将永久删除, 是否继续?',
        'confirm-text': '确定',
        'refuse-text': '取消',
      })
        .then(() => {
          this.tableLoading = true;
          this.$axios({
            url: deleteDistributionSitesYC,
            method: 'post',
            data: {
              distributionId: row.distributionId,
            },
          }).then((res) => {
            this.getDistributionSitesYCList();
          });
        })
        .finally((err) => {
          console.log(err);
        });
    },
    // 新建科室中的省市区
    // 初始化默认获取省的数据
    getDefaultProvinceData() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          countryCode: 'CN',
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.provinceDataKS = this.handleData(result);
          // 清空该行下的市和区
        })
        .catch(() => {
          // this.provinceData[0] = []
        });
    },
    // 修改省的数据时，获取市的数据
    provinceMethod() {
      this.addNewOff.province = this.provinceDataKS.find((item) =>
        Object.is(this.addNewOff.province, item.value)
      ).value;

      // 清空市、区
      this.addNewOff.city = '';
      this.addNewOff.cityId = '';
      this.addNewOff.county = '';
      if (this.addNewOff.province) this.getCityList();
    },
    // 获取市数据的接口调用
    getCityList() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          provinceCode: this.addNewOff.province,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.cityDataKS = this.handleData(result);
        })
        .catch(() => {
          // this.cityData[this.tableIndex] = []
        });
    },
    // 修改市的数据时，获取区的数据
    cityMethod() {
      this.addNewOff.city = this.cityDataKS.find((item) =>
        Object.is(this.addNewOff.city, item.value)
      ).value;
      this.addNewOff.county = '';
      if (this.addNewOff.city) this.getCountyList();
    },
    handleData(result) {
      const arr = [];
      for (const key in result) {
        arr.push({
          value: [key][0],
          label: result[key],
        });
      }
      return arr;
    },
    // 获取区数据的接口
    getCountyList() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          cityCode: this.addNewOff.city,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.countyDataKS = this.handleData(result);
        })
        .catch(() => {});
    },
    countyMethod() {
      this.addNewOff.county = this.countyDataKS.find((item) =>
        Object.is(this.addNewOff.county, item.value)
      ).value;
      this.$forceUpdate();
      // console.log(this.addNewOff.county,'this.addNewOff.county')
    },

    // 收件地址的省市区
    getDefaultProvinceDataSJ() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          countryCode: 'CN',
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.provinceDataSJ = this.handleDataSJ(result);
          // 清空该行下的市和区
        })
        .catch(() => {
          // this.provinceData[0] = []
        });
    },
    // 修改省的数据时，获取市的数据
    provinceMethodSJ() {
      this.editConsigneeAddress.province = this.provinceDataSJ.find((item) =>
        Object.is(this.editConsigneeAddress.province, item.value)
      ).value;

      // 清空市、区
      this.editConsigneeAddress.city = '';
      this.editConsigneeAddress.cityId = '';
      this.editConsigneeAddress.county = '';
      if (this.editConsigneeAddress.province) this.getCityListSJ();
    },
    // 获取市数据的接口调用
    getCityListSJ() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          provinceCode: this.editConsigneeAddress.province,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.cityDataSJ = this.handleDataSJ(result);
        })
        .catch(() => {
          // this.cityData[this.tableIndex] = []
        });
    },
    // 修改市的数据时，获取区的数据
    cityMethodSJ() {
      this.editConsigneeAddress.city = this.cityDataSJ.find((item) =>
        Object.is(this.editConsigneeAddress.city, item.value)
      ).value;
      this.editConsigneeAddress.county = '';
      if (this.editConsigneeAddress.city) this.getCountyListSJ();
    },
    handleDataSJ(result) {
      const arr = [];
      for (const key in result) {
        arr.push({
          value: [key][0],
          label: result[key],
        });
      }
      return arr;
    },
    // 获取区数据的接口
    getCountyListSJ() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          cityCode: this.editConsigneeAddress.city,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.countyDataSJ = this.handleDataSJ(result);
        })
        .catch(() => {});
    },
    countyMethodSJ() {
      this.editConsigneeAddress.county = this.countyDataSJ.find((item) =>
        Object.is(this.editConsigneeAddress.county, item.value)
      ).value;
      // console.log(this.addNewOff.county,'this.addNewOff.county')
    },

    // 阳采新建弹框中的省市区
    getDefaultProvinceDataYC() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          countryCode: 'CN',
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.provinceDataYC = this.handleDataYC(result);
          // 清空该行下的市和区
        })
        .catch(() => {
          // this.provinceData[0] = []
        });
    },
    // 修改省的数据时，获取市的数据
    provinceMethodYC() {
      this.addFormYC.province = this.provinceDataYC.find((item) =>
        Object.is(this.addFormYC.province, item.value)
      ).value;

      // 清空市、区
      this.addFormYC.city = '';
      this.addFormYC.cityId = '';
      this.addFormYC.county = '';
      if (this.addFormYC.province) this.getCityListYC();
    },
    // 获取市数据的接口调用
    getCityListYC() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          provinceCode: this.addFormYC.province,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.cityDataYC = this.handleDataYC(result);
        })
        .catch(() => {
          // this.cityData[this.tableIndex] = []
        });
    },
    // 修改市的数据时，获取区的数据
    cityMethodYC() {
      this.addFormYC.city = this.cityDataYC.find((item) =>
        Object.is(this.addFormYC.city, item.value)
      ).value;
      this.addFormYC.county = '';
      if (this.addFormYC.city) this.getCountyListYC();
    },
    handleDataYC(result) {
      const arr = [];
      for (const key in result) {
        arr.push({
          value: [key][0],
          label: result[key],
        });
      }
      return arr;
    },
    // 获取区数据的接口
    getCountyListYC() {
      this.$axios({
        method: 'get',
        url: this.queryArea,
        params: {
          cityCode: this.addFormYC.city,
        },
      })
        .then((res) => {
          const result = res.data.payload;
          this.countyDataYC = this.handleDataYC(result);
        })
        .catch(() => {});
    },
    countyMethodYC() {
      this.addFormYC.county = this.countyDataYC.find((item) =>
        Object.is(this.addFormYC.county, item.value)
      ).value;
      // console.log(this.addNewOff.county,'this.addNewOff.county')
    },
  },
};
</script>
<style scoped lang="less">
.factory-assessment-box {
  .demo-ruleForm {
    .el-input,
    .el-select {
      width: 100%;
    }
    /deep/ .el-form-item__content {
      width: 217px;
    }
  }
  .infoSty {
    font-size: 18px;
    margin: 18px 10px 18px 10px;
    padding: 0 0 18px 0;
    border-bottom: 1px solid #ccc;
    .btnSty {
      margin: 0 0 0 1100px;
    }
  }
  margin: 0 0 10px 0 !important;
  .factory-assessment-container {
    height: 100%;
    overflow: auto;
    .action-button-box {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
      padding: 0 20px;
    }
    .pageBox {
      margin: 0 20px !important;
      padding: 7px 26px 6px 0;
      border: 1px solid @cutOffRuleColor;
      border-top: none;
      border-radius: 0 0 3px 3px;
    }
  }
  .tab {
    margin-bottom: 20px;
  }
  .footer {
    padding: 7px 26px 6px 0;
    border: 1px solid @cutOffRuleColor;
    border-top: none;
    border-radius: 0 0 3px 3px;
  }
  .topSty {
    display: flex;
    justify-content: space-between;
    el-input {
      align-items: baseline;
    }
  }
  .butSty {
    display: flex;
    justify-content: space-between;
  }
}
</style>
